/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Action;

import Entity.AboutUs;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author duongdm_b00092
 */
@Stateless
@LocalBean
public class AboutUsSessionBean {

    @PersistenceContext
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    public List<AboutUs> viewAllAboutUs() {
        List<AboutUs> list = em.createNamedQuery("AboutUs.findAll").getResultList();
        return list;
    }

    public void addAboutUs(AboutUs au) {
        em.persist(au);
    }

    public void updateAboutUs(int id, String content) {

        AboutUs ab = em.find(AboutUs.class, id);
        ab.setContent(content);
        em.persist(ab);
        
    }

    public void deleteAboutUs(AboutUs au) {
        em.remove(em.merge(au));
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
